/*
 * @Description: 表单数据存储-step2
 * @Author: ziwei.ma
 * @Date: 2019-08-14 18:09:45
 * @Last Modified by: ziwei.ma
 * @Last Modified time: 2019-08-14 18:40:58
 */
const state = {
  userName: '', // 联系人姓名
  userPhone: '', // 联系人电话
  isSecondUser: true, // 其他联系人默认选中
  isEmail: false, // 其他联系方式默认不选中
  secondUserName: '',
  secondUserPhone: '',
  eMail: '',
  remark: '',
  wordsNum: 0
}

const getters = {
  userName: state => state.userName,
  userPhone: state => state.userPhone,
  isSecondUser: state => state.isSecondUser,
  isEmail: state => state.isEmail,
  secondUserName: state => state.secondUserName,
  secondUserPhone: state => state.secondUserPhone,
  eMail: state => state.eMail,
  remark: state => state.remark,
  wordsNum: state => state.wordsNum
}

const actions = {
  fetchUserName: ({ commit, state }, text) => {
    commit('updateUserName', text)
  },
  fetchUserPhone: ({ commit, state }, text) => {
    commit('updateUserPhone', text)
  },
  fetchIsSecondUser: ({ commit, state }, text) => {
    commit('updateIsSecondUser', text)
  },
  fetchIsEmail: ({ commit, state }, text) => {
    commit('updateIsEmail', text)
  },
  fetchSecondUserName: ({ commit, state }, text) => {
    commit('updatesecondUserName', text)
  },
  fetchSecondUserPhone: ({ commit, state }, text) => {
    commit('updateSecondUserPhone', text)
  },
  fetchEMail: ({ commit, state }, text) => {
    commit('updateEMail', text)
  },
  fetchRemark: ({ commit, state }, text) => {
    commit('updateRemark', text)
  },
  fetchWordsNum: ({ commit, state }, text) => {
    commit('updateWordsNum', text)
  }
}

const mutations = {
  updateUserName: (state, userName) => {
    state.userName = userName
  },
  updateUserPhone: (state, userPhone) => {
    state.userPhone = userPhone
  },
  updateIsSecondUser: (state, isSecondUser) => {
    state.isSecondUser = isSecondUser
  },
  updateIsEmail: (state, isEmail) => {
    state.isEmail = isEmail
  },
  updatesecondUserName: (state, secondUserName) => {
    state.secondUserName = secondUserName
  },
  updateSecondUserPhone: (state, secondUserPhone) => {
    state.secondUserPhone = secondUserPhone
  },
  updateEMail: (state, eMail) => {
    state.eMail = eMail
  },
  updateRemark: (state, remark) => {
    state.remark = remark
  },
  updateWordsNum: (state, wordsNum) => {
    state.wordsNum = wordsNum
  }
}
export default {
  state,
  getters,
  actions,
  mutations
}
